# -*- coding: utf-8 -*-
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression   #导入线性回归算法
from sklearn.linear_model import MultiTaskElasticNetCV
from sklearn import preprocessing
from six.moves import reload_module
from sklearn.model_selection import cross_val_score

scores = [0.00000000000000001]


loaded_data = datasets.load_boston()  #波士顿房价数据
data_x = loaded_data.data
data_y = loaded_data.target

x_train,x_test,y_train,y_test = train_test_split(data_x,data_y,test_size=0.3)
module = LinearRegression()
module.fit(x_train,y_train)
if module.score(x_test,y_test) > max(scores):
    print(module.score(x_test,y_test))



    # print "训练结果："x
    # print module.predict(x_test[:4,:])    #预测并查看训练结果
    # print y_test[:4]


    #print module.coef_    #y = 0.1x + 0.3   就输出0.1
    #print module.intercept_    #输出0.3
    #print module.score(x_test,y_test)    #准确度
    scores.append(module.score(x_test,y_test))
print(max(scores))